import { ref } from "vue";
import { ListgroupItem } from "../listgroup/listgroup.type";

export default function(props: any,selectedItems: any){
  const data = ref<ListgroupItem[]>(props.data);
  return {
    setData(isAll: boolean,_data?: ListgroupItem[]){
      if(isAll){
        //props中的data最全 如果数量一致 则说明数据没有变化 最全数据
        if(props.data.length === data.value.length){
          return;
        }
        _data = props.data;
      }else if(!_data){
        throw("need to define data");
      }
      data.value = _data as ListgroupItem[];
    }
  };
}